//
//  FocuseDoctorViewController.m
//  FastMedical
//
//  Created by 李通 on 16/7/6.
//  Copyright © 2016年 chivalrous. All rights reserved.
//

#import "FocuseDoctorViewController.h"
#import "attentionDoctorsCell.h"
#import "attentionDoctorsModel.h"
#import "doctorsynopsisController.h"

@interface FocuseDoctorViewController ()<UITableViewDelegate,UITableViewDataSource >

@property(nonatomic,weak)UITableView * attentionDoctorsView;
@property (nonatomic, strong) NSArray *focusList;

@end
static NSString *identifier = @"cell";

@implementation FocuseDoctorViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    UITableView * attentionDoctorsView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    
    _attentionDoctorsView = attentionDoctorsView;
    [self.view addSubview:attentionDoctorsView];
    attentionDoctorsView.dataSource = self;
    attentionDoctorsView.delegate = self;
    
    
    
    self.attentionDoctorsView.backgroundColor =[UIColor colorWithRed:247/265.0 green:247/265.0 blue:247/265.0 alpha:1.0];
    
    [self.attentionDoctorsView registerClass:[attentionDoctorsCell class] forCellReuseIdentifier:identifier];
    [self setupUI];
    
    
}
-(void)setFocusList:(NSArray *)focusList{
    
    _focusList = focusList;
    
    [_attentionDoctorsView reloadData];
}
-(void)setupUI
{
    
    [attentionDoctorsModel focusListWithSuccess:^(NSArray<attentionDoctorsModel *> *focusList)
    {
        self.focusList = focusList;
    } error:^{
        NSLog(@"error2");
    }];



}


//多少列
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.focusList.count;
}



-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    attentionDoctorsCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    

    cell.model = self.focusList[indexPath.row];
    
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 110;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    doctorsynopsisController * doctorsynopsisVC = [[doctorsynopsisController alloc]init];
    
    
    attentionDoctorsModel * model = self.focusList[indexPath.row];
    
    doctorsynopsisVC.model =model;
    [self.navigationController pushViewController:doctorsynopsisVC animated:YES];
    
    
}
@end



























